#include "formworkwindow.h"
#include "ui_formworkwindow.h"

FormWorkWindow::FormWorkWindow(QWidget *parent) :
    QWidget(parent),
    mp_widget(NULL),
    ui(new Ui::FormWorkWindow)
{
    ui->setupUi(this);
}

FormWorkWindow::~FormWorkWindow()
{
    delete ui;
}

void FormWorkWindow::set_widget(QWidget *p_widget)
{
    if(mp_widget != NULL)
    {
        ui->layout_work->removeWidget(mp_widget);
        mp_widget->hide();
    }
    this->resize(p_widget->size());
    mp_widget = p_widget;
    ui->layout_work->addWidget(mp_widget);
    mp_widget->show();
//    QRect qr_parent = parentWidget()->geometry();
//    QPoint qp_c = (qr_parent.topLeft() + qr_parent.bottomRight())/2;
//    QPoint qp_m;
//    qp_m.setX(qp_c.x() - this->size().width()/2);
//    qp_m.setY(qp_c.y() - this->size().height()/2);
//    if(qp_m.x() < 10) qp_m.setX(10);
//    if(qp_m.y() < 10) qp_m.setY(10);
//    this->move(qp_m);
}

void FormWorkWindow::set_title(const QString &qstr_title)
{
    this->setWindowTitle(qstr_title);
}
